package org.example.mydeom.util;

import com.alibaba.fastjson.JSON;
import jakarta.servlet.http.HttpServletResponse;
import org.example.mydeom.result.Result;

import java.io.IOException;

public class ResultUtil {

    public static void Respond(String msg, String data, int code,HttpServletResponse response) throws IOException {
        Result<Object> result = new Result<>();
        result.setCode(code);
        result.setMsg(msg);
        result.setData(data);
        String jsonString = JSON.toJSONString(result);
        response.setContentType("application/json;charset=UTF-8");
        response.getWriter().write(jsonString);
    }
}
